package com.htfyun.factorytest.utils;

import android.text.TextUtils;

public class LightSensorUtil {
    public static final String LIGHT_SENSOR1_VALUE = "/sys/class/ls_stk3x1x/lux_value";
    public static final String LIGHT_SENSOR2_VALUE = "/sys/class/ls_ltr578/lux_value";

    public static int getLightSensor1Value() {
        return getLightSensorValue(LIGHT_SENSOR1_VALUE);
    }

    public static int getLightSensor2Value() {
        return getLightSensorValue(LIGHT_SENSOR2_VALUE);
    }

    private static int getLightSensorValue(String path) {
//        File f = new File(path);
//        DebugLog.d("canRead=" + f.canRead() + ", canWrite" + f.canWrite() + ", canExecute" + f.canExecute());
        String sensorValueStr = FileReadWrite.readFileByLines(path);
        if (TextUtils.isEmpty(sensorValueStr)) {
            DebugLog.e("Read the node can not get the current sensor value");
            return -1;
        }
        int sensorValue = Integer.parseInt(sensorValueStr);
        DebugLog.d("sensorValue = " + sensorValue);
        return sensorValue;
    }
}
